package org.example;

import java.util.*;
import java.util.stream.Collectors;

public class Company {
    private double income;
    private ArrayList<Employee> employees = new ArrayList<>();

    public Company(double income) {
        this.income = income;
    }

    public void hire(Employee employee) {
        employees.add(employee);
    }

    public void hireAll(Collection<Employee> employees) {
        this.employees.addAll(employees);
    }

    public void fire(Employee employee) {
        employees.remove(employee);
    }

    public double getIncome() {
        return income;
    }

    public List<Employee> getTopSalaryStaff(int count) {
        if (count > 0) {
            return employees.stream()
                .sorted(Comparator.comparing(Employee::getMonthSalary).reversed())
                .limit(count)
                .collect(Collectors.toList());
        } else {
            return Collections.emptyList();
        }
    }

    public List<Employee> getLowestSalaryStaff(int count) {
        if (count > 0) {
            return employees.stream()
                    .sorted(Comparator.comparing(Employee::getMonthSalary))
                    .limit(count)
                    .collect(Collectors.toList());
        } else {
            return Collections.emptyList();
        }
    }

    public List<Employee> getStaff() {
        return new ArrayList<>(employees);
    }
}
